﻿
Imports System.Data.SqlClient

Public Class DLSecurity
    Inherits DLBase

#Region "Declaration"

    Private m_sForeignKey As String
    Private m_sStoreGetByforeignKey As String = "Proc_DI_Select_"
    Private m_sStoreDeleteByforeignKey As String = "Proc_DI_Delete_"

#End Region

#Region "Property"

    Public Property ForeignKey() As String
        Get
            Return m_sForeignKey
        End Get
        Set(ByVal value As String)
            m_sForeignKey = value
            m_sStoreGetByforeignKey += TableName + "sBy" + m_sForeignKey
            m_sStoreDeleteByforeignKey += TableName + "sBy" + m_sForeignKey
        End Set
    End Property

#End Region

#Region "Constructor"

    Public Sub New(ByVal databaseConnectionName As String)
        MyBase.New(databaseConnectionName)
        strSubSystemCode = "DI"
    End Sub

#End Region

#Region "Method"

#Region "Private Method"

#End Region

#Region "Public Method"

    'Proc_SYS_GetPermissionList_ByActorID
    ''' <summary>
    ''' GetAllData
    ''' </summary>
    ''' <param name="table"></param>
    Public Sub GetPermissionList_ByActorID(ByRef table As DataTable, ByVal ParamArray oPara As Object())
        db.LoadDataSet("Proc_SYS_GetPermissionList_ByActorID", table.DataSet, New String() {table.TableName}, oPara)
    End Sub

    Public Function CheckPermissionByActor(ByVal ParamArray oPara As Object()) As Boolean
        Return (db.ExecuteScalar("Proc_SYS_CheckPermissionByID", oPara) > 0)
    End Function

    Public Shared Function CheckLogIn(ByVal sConnectionString As String, ByVal strUser As String, _
                                      ByVal encryptPass As String) As Integer
        Dim cnn As SqlConnection = New SqlConnection(sConnectionString)
        Dim cmd As SqlCommand = New SqlCommand("Proc_DI_CheckLogIn", cnn)
        Dim eResult As Integer = 1
        Try
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.AddWithValue("@UserName", strUser)
            cmd.Parameters.AddWithValue("@Password", encryptPass)

            cnn.Open()
            eResult = cmd.ExecuteScalar()
        Catch ex As Exception
            Throw
        Finally
            cnn.Close()
            cnn.Dispose()
        End Try
        Return eResult
    End Function

#End Region

#Region "Overridable"

#End Region

#End Region

#Region "Event"

#Region "Form event"

#End Region

#Region "Control event"

#End Region

#Region "User event"

#End Region

#End Region
End Class
